#ifndef __M_CONSUMER_H__
#define __M_CONSUMER_H__
#include"../mqcommon/mq_helper.hpp"
#include"../mqcommon/mq_msg.pb.h"
#include<iostream>
#include<unordered_map>
#include<mutex>
#include<memory>
#include<vector>
#include<functional>

namespace xiang11mq
{

//消费者标识 消息的属性 消息的主体
using ConsumerCallback = std::function<void(const std::string tag, BasicProperties *bp, const std::string body)>;
//消费者对象结构
struct Consumer
{
    using ptr = std::shared_ptr<Consumer>;

    std::string tag;                    //消费者标识
    std::string subscribe_queue;        //消费者订阅的队列名称
    bool auto_ack;                      //自动确认标志
    ConsumerCallback callback;

    Consumer(){
        DLOG("new Channel by default: %p", this);
    }
    Consumer(const std::string &ctag, const std::string &csubscribe_queue, bool ack, const ConsumerCallback &cb)
        :tag(ctag)
        ,subscribe_queue(csubscribe_queue)
        ,auto_ack(ack)
        ,callback(cb)
    {
        DLOG("new consumer: %p", this);
    }
    ~Consumer()
    {
        DLOG("del consumer: %p", this);
    }
};

}

#endif